package top.fzqblog.test

/**
 * Created by 抽离 on 2017/7/29 0029.
 */
fun main(args: Array<String>) {
    case(1)
    case("2")
    case("啦啦啦")
    println("转换颜色：" + transformColor("red") )
}

fun transformColor(color: String): Int{
    return when(color){
        "red" -> 1
        "green" -> 2
        else -> throw IllegalArgumentException("Invalid color param value")
    }
}

fun case(obj : Any){
    when(obj){
        1 -> println("obj is 1")
        2 -> println("obj is 2")
        is Int -> println("obj is Int")
        else -> println("obj is j8")
    }
}